package com.example.ims.service;

import com.example.ims.repository.CommodityRepository;
import com.example.ims.service.inf.SalesOrderServiceInf;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import com.example.ims.pojo.SalesOrder;
import com.example.ims.repository.SalesOrderRepository;
import com.example.ims.service.SalesOrderService;

@Service
@Transactional
public class SalesOrderService implements SalesOrderServiceInf {
    @Autowired
    public SalesOrderRepository salesOrderRepository;


    public List<SalesOrder> findAllOrders() {
        return salesOrderRepository.findAll();
    }


    public SalesOrder findById(Long id) {
        return salesOrderRepository.findById(id).orElse(null);
    }


    public void addOrder(SalesOrder order) {
        salesOrderRepository.save(order);
    }


    public void updateOrder(SalesOrder order) {
        salesOrderRepository.save(order);
    }


    public void deleteOrder(Long id) {
        salesOrderRepository.deleteById(id);
    }
}